<?php

use app\assets\BackendAsset as Asset;
use app\models\tableModel\AdminRoleModel;

/* @var $this yii\web\View */

?>
<el-container class="index-wrapper">
    <el-header class="top-wrapper bg-white" :class="getTopClass" height="auto" ref="mainScrollShadow">
        <el-row :inline="true" class="button-container">
            <el-col :xs="12" :sm="12" :md="12" :lg="5">
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item>
                        <a @click="goToIndex"><i class="el-icon-location-outline"></i>&nbsp;首页</a>
                    </el-breadcrumb-item>
                    <el-breadcrumb-item>操作员管理</el-breadcrumb-item>
                </el-breadcrumb>
            </el-col>
            <el-col :xs="12" :sm="12" :md="12" :lg="19" class="text-right">
                <?php if (AdminRoleModel::checkAuth('create')) { ?>
                    <el-button class="" size="mini" type="success" @click.native="goToCreate()">
                        新建
                    </el-button>
                <?php } ?>
                <?php if (AdminRoleModel::checkAuth('export')) { ?>
                    <el-button class="ml-5" size="mini" type="primary" @click.native="exportConfirm()">
                        导出
                    </el-button>
                <?php } ?>
                <el-dropdown size="mini" class="ml-15">
                    <el-button type="primary" size="mini">
                        更多操作
                        <i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <?php if (AdminRoleModel::checkAuth('open')) { ?>
                            <el-dropdown-item size="mini" @click.native="openItem(null)">
                                批量恢复
                            </el-dropdown-item>
                        <?php } ?>
                        <?php if (AdminRoleModel::checkAuth('disabled')) { ?>
                            <el-dropdown-item size="mini" @click.native="disabledItem(null)" divided>
                                批量禁用
                            </el-dropdown-item>
                        <?php } ?>
                </el-dropdown>
            </el-col>
        </el-row>
    </el-header>
    <el-main class="content-wrapper transits">
        <!-- 查询 START -->
        <?= $this->render('../common/search.php', [
            'groupFields'      => 'searchForm.group',
            'groupOtherFields' => 'searchForm.groupOther',
            'baseFields'       => 'searchForm.base',
            'moreFields'       => 'searchForm.more',
            'export'           => 'searchForm.value',
            'submit'           => 'handleCurrentChange'
        ]); ?>
        <!-- 查询 START -->
        <!-- 主列表 表格 START -->
        <el-table :data="dataList" style="width: 100%" class=""
                  @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>

            <el-table-column fixed prop="id" label="编号" width="100">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="light" :content="scope.row.id"
                                placement="top-start">
                        <div class="text-more-ellipsis">
                            <span v-text="scope.row.id" class="pointer"></span>
                        </div>
                    </el-tooltip>
                </template>
            </el-table-column>

            <el-table-column fixed prop="user_name" label="账号">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="light" :content="scope.row.user_name"
                                placement="top-start">
                        <div class="text-more-ellipsis">
                            <span v-text="scope.row.user_name" class="pointer"></span>
                        </div>
                    </el-tooltip>
                </template>
            </el-table-column>

            <el-table-column fixed prop="nick_name" label="昵称">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="light" :content="scope.row.nick_name"
                                placement="top-start">
                        <div class="text-more-ellipsis">
                            <span v-text="scope.row.nick_name" class="pointer"></span>
                        </div>
                    </el-tooltip>
                </template>
            </el-table-column>

            <el-table-column fixed prop="role_name" label="所属角色" width="120">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="light" :content="scope.row.role_name"
                                placement="top-start">
                        <div class="text-more-ellipsis">
                            <span v-text="scope.row.role_name" class="pointer"></span>
                        </div>
                    </el-tooltip>
                </template>
            </el-table-column>

            <el-table-column prop="update_time" label="修改时间" width="120">
                <template slot-scope="scope">
                    <el-tooltip class="item" effect="light"
                                :content="scope.row.update_time_text"
                                placement="top-start">
                        <div class="text-more-ellipsis">
                            <span v-text="scope.row.update_time_text_s"
                                  class="pointer"></span>
                        </div>
                    </el-tooltip>
                </template>
            </el-table-column>

            <el-table-column prop="status_text" label="状态" width="80">
                <template slot-scope="scope">
                    <div class="text-more-ellipsis">
                        <span v-if="scope.row.status == setting.status_list.disabled.value"
                              v-text="scope.row.status_text"
                              class="text-danger"></span>
                        <span v-else v-text="scope.row.status_text" class="text-success"></span>
                    </div>
                </template>
            </el-table-column>

            <el-table-column fixed="right" label="操作" width="180" class-name="operate-column">
                <template slot-scope="scope">
                    <?php if (AdminRoleModel::checkAuth('update')) { ?>
                        <el-button type="text" size="small" @click.native="goToUpdate(scope.row.id)">
                            编辑
                        </el-button>
                    <?php } ?>
                    <?php if (AdminRoleModel::checkAuth('changePassword')) { ?>
                        <el-button type="text" size="small" @click.native="changePwd(scope.row.id)">
                            改密
                        </el-button>
                    <?php } ?>
                    <?php if (AdminRoleModel::checkAuth('disabled')) { ?>
                        <el-button v-if="scope.row.status != setting.status_list.disabled.value"
                                   type="text text-danger" size="small"
                                   @click.native="disabledItem(scope.row.id)">禁用
                        </el-button>
                    <?php } ?>
                    <?php if (AdminRoleModel::checkAuth('open')) { ?>
                        <el-button type="text text-success" size="small" v-else
                                   @click.native="openItem(scope.row.id)">开启
                        </el-button>
                    <?php } ?>
                </template>
            </el-table-column>
        </el-table>
        <!-- 主列表 表格 END -->

        <!-- 分页 START -->
        <div class="block pagination" v-if="dataTotal >= pageSize">
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="page"
                           :page-sizes="[20, 50, 100, 200]"
                           :page-size="pageSize"
                           layout="total, sizes, prev, pager, next, jumper"
                           :total="dataTotal">
            </el-pagination>
        </div>
        <!-- 分页 END -->

        <div class="clean-80px" v-else></div>
    </el-main>
</el-container>

<!-- 导入 开始 -->
<?= $this->render('../common/import.php', [
    'scenario'  => 'setting.scenario',
    'isShow'    => 'importDialog.isShow',
    'importUrl' => 'importDialog.url',
    'endCallback'  => 'getList()'
]) ?>
<!-- 导入 结束 -->

<?= Asset::addCss($this, '/css/backend/admin-user-index.css'); ?>

<?= Asset::addScript($this, '/js/backend/admin-user-index.js'); ?>
<?= $this->registerJs('
    instance = new app();
'); ?>
